{extend name="public:base"/}


{block name="title"}编辑<?=$config['tableCnName']?>{/block}
{block name="style"}{/block}

{block name="main"}

<section class="content" xmlns="http://www.w3.org/1999/html">
    <div class="row">

        <div class="col-md-12">

            <div class="row">
                <div class="col-lg-12">
                    <div class="box">
                        <div class="box-header with-border">
                            <h3 class="box-title">编辑<?=$config['tableCnName']?></h3>
                        </div>
                        <form  id="pt_form" method="post">
                            <div class="box-body">

                                <input type="hidden" name="<?=$config['pri_key']?>" value="<?php echo '<?=$model[\''.$config['pri_key'].'\']?>';?>" ?>
                                <div class="clearfix"></div>

<?php
     foreach($config['form_fields'] as $k=>$v){
        if(!isset($v['type']) || $v['type'] == ''){
            continue;
        }
?>
     <?php if($v['type'] == 'text'){ ?>

                                <div class="form-group <?=isset($v['required'])&&$v['required']?'required':''?>">
                                    <div class='col-sm-2 text-right'>
                                        <label for="<?=$k?>" class="control-label Validform_label" ><?=$v['text']?></label>
                                    </div>
                                    <div class='col-sm-10'>
                                        <input type="text" id="<?=$k?>" class="form-control" name="<?=$k?>" placeholder="<?=$v['placeholder']?>" value="<?php echo '<?=$model[\''.$k.'\']?>';?>" <?=$v['validate']?>>
                                        <div class="help-block"></div>
                                    </div>
                                </div>
     <?php }elseif($v['type'] == 'password'){?>

                                <div class="form-group <?=isset($v['required'])&&$v['required']?'required':''?>">
                                    <div class='col-sm-2 text-right'>
                                        <label for="<?=$k?>" class="control-label Validform_label" ><?=$v['text']?></label>
                                    </div>
                                    <div class='col-sm-10'>
                                        <input type="password" id="<?=$k?>" class="form-control" name="<?=$k?>" placeholder="<?=$v['placeholder']?>" <?=$v['validate']?>>
                                        <div class="help-block"></div>
                                    </div>
                                </div>

                                <div class="form-group <?=isset($v['required'])&&$v['required']?'required':''?>">
                                    <div class='col-sm-2 text-right'>
                                        <label for="re<?=$k?>" class="control-label Validform_label" ><?=$v['text']?></label>
                                    </div>
                                    <div class='col-sm-10'>
                                        <input type="password" id="re<?=$k?>" class="form-control" name="re<?=$k?>" placeholder="<?=$v['placeholder']?>" <?=$v['validate']?> recheck="<?=$k?>">
                                        <div class="help-block"></div>
                                    </div>
                                </div>

<?php }else if($v['type'] == 'select'){ ?>

                                <div class="form-group <?=isset($v['required'])&&$v['required']?'required':''?>" >
                                    <div class='col-sm-2 text-right'>
                                        <label class="control-label" for="<?=$k?>"><?=$v['text']?></label>
                                    </div>
                                    <div class='col-sm-10'>

                                        <select id="<?=$k?>" class="form-control" name="<?=$k?>">
                                            <option value="0">请选择</option>
                                            <?php if(!empty($v['values'])){foreach($v['values'] as $k1=>$v1):?>
                                            <option value="<?=$k1?>"><?=$v1?></option>
                                            <?php endforeach;}?>
                                        </select>
                                        <div class="help-block"></div>
                                    </div>
                                </div>
<?php }elseif($v['type'] == 'textarea'){ ?>

                                <div class="form-group <?=isset($v['required'])&&$v['required']?'required':''?>">
                                    <div class='col-sm-2 text-right'>
                                        <label for="<?=$k?>" class="control-label Validform_label" ><?=$v['text']?></label>
                                    </div>
                                    <div class='col-sm-10'>

                                        <textarea id="<?=$k?>" class="form-control" name="<?=$k?>" placeholder="<?=$v['placeholder']?>" <?=$v['validate']?> > <?php echo '<?=$model[\''.$k.'\']?>'?></textarea>
                                        <div class="help-block"></div>
                                    </div>
                                </div>
<?php }elseif($v['type'] == 'checkbox'){ ?>

                                <div class="form-group <?=isset($v['required'])&&$v['required']?'required':''?>">
                                    <div class="col-sm-2 text-right">
                                        <label class="control-label Validform_label" for="<?=$k?>"><?=$v['text']?></label>
                                    </div>

                                    <div class="col-sm-10">
                                        <div id="article-position">
                                            <?php if(!empty($v['values'])){foreach($v['values'] as $k1=>$v1):?>

                                            <span style="color:#636f7a">
                                                <input type="checkbox" name="<?=$k?>[]" value="<?=$k1?>" <?php if($k1==0){echo $v['validate'];}?>><?=$v1?>
                                            </span>
                                            <?php endforeach;}?>
                                        </div>

                                        <div class="help-block"></div>
                                    </div>
                                </div>
<?php  }elseif($v['type'] == 'radio'){ ?>

                                <div class="form-group <?=isset($v['required'])&&$v['required']?'required':''?>">
                                    <div class="col-sm-2 text-right">
                                        <label class="control-label Validform_label"><?=$v['text']?>
                                        </label>
                                    </div>

                                    <div class="col-sm-10">
                                        <div>
                                      <?php if(!empty($v['values'])){foreach($v['values'] as $k1=>$v1){?>

                                            <span style="color:#636f7a"><input type="radio" name="<?=$k?>" value="<?=$k1?>" <?php if($k1==0){echo $v['validate'];}?>><?=$v1?></span>

                                            <?php }} ?>
                                        </div>
                                        <div class="help-block"></div>
                                    </div>
                                </div>


<?php }}?>
                            </div>
                            <div class="box-footer text-center">
                                <button class="btn btn-primary" type="submit">保存</button>
                                <span class="btn btn-white" onclick="history.go(-1)">返回</span>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>
{/block}

{block name="js"}
<script>

    var validate = validator('#pt_form');
    
</script>
{/block}